diff options
Diffstat (limited to 'plugins/Goals/templates/GoalForm.js')
-rw-r--r-- | plugins/Goals/templates/GoalForm.js | 111 |
1 files changed, 46 insertions, 65 deletions
diff --git a/plugins/Goals/templates/GoalForm.js b/plugins/Goals/templates/GoalForm.js index 13ed40ba5e..f3c5af4227 100644 --- a/plugins/Goals/templates/GoalForm.js +++ b/plugins/Goals/templates/GoalForm.js @@ -1,35 +1,18 @@ function showAddNewGoal() { - hideForms(); $("#GoalForm").show(); - showCancel(); - piwikHelper.lazyScrollTo("#AddEditGoals", 400); + $("#EditGoals").hide(); + $.scrollTo("#AddEditGoals", 400); return false; } function showEditGoals() { - hideForms(); $("#EditGoals").show(); - showCancel(); - piwikHelper.lazyScrollTo("#AddEditGoals", 400); - return false; -} - -function hideForms() -{ $("#GoalForm").hide(); - $("#EditGoals").hide(); -} - -function showCancel() -{ - $("#goalsCancel").show(); - $('#goalsCancelLink').click( function(){ - hideForms(); - $("#goalsCancel").hide(); - }); + $.scrollTo("#AddEditGoals", 400); + return false; } // init the goal form with existing goal value, if any @@ -59,6 +42,11 @@ function initGoalForm(goalMethodAPI, submitText, goalName, matchAttribute, patte } } +function initAndShowAddGoalForm() +{ + initGoalForm('Goals.addGoal', 'Add Goal', '', 'url', '', 'contains', false, '0'); + return showAddNewGoal(); +} function bindGoalForm() { @@ -90,85 +78,78 @@ function bindGoalForm() $('a[name=linkAddNewGoal]').click( function(){ initAndShowAddGoalForm(); - piwikHelper.lazyScrollTo('#goal_name'); } ); } +function bindListGoalEdit() +{ + $('a[name=linkEditGoal]').click( function() { + var goalId = $(this).attr('id'); + var goal = piwik.goals[goalId]; + initGoalForm("Goals.updateGoal", "Update Goal", goal.name, goal.match_attribute, goal.pattern, goal.pattern_type, (goal.case_sensitive=='0' ? false : true), goal.revenue, goalId); + showAddNewGoal(); + return false; + }); + + $('a[name=linkDeleteGoal]').click( function() { + var goalId = $(this).attr('id'); + var goal = piwik.goals[goalId]; + if(confirm(sprintf("Are you sure you want to delete the Goal '%s'?", goal.name))) + { + $.ajax( getAjaxDeleteGoal( goalId ) ); + } + return false; + }); + + $('a[name=linkEditGoals]').click( function(){ + return showEditGoals(); + } ); +} function getAjaxDeleteGoal(idGoal) { - var ajaxRequest = piwikHelper.getStandardAjaxConf('goalAjaxLoading'); - piwikHelper.lazyScrollTo("#AddEditGoals", 400); + var ajaxRequest = piwikHelper.getStandardAjaxConf(); + piwikHelper.toggleAjaxLoading(); var parameters = {}; parameters.idSite = piwik.idSite; - parameters.idGoal = idGoal; - parameters.method = 'Goals.deleteGoal'; + parameters.idGoal = idGoal; + parameters.method = 'Goals.deleteGoal'; parameters.module = 'API'; parameters.format = 'json'; - parameters.token_auth = piwik.token_auth; + parameters.token_auth = piwik.token_auth; ajaxRequest.data = parameters; return ajaxRequest; } function getAjaxAddGoal() { - var ajaxRequest = piwikHelper.getStandardAjaxConf('goalAjaxLoading'); - piwikHelper.lazyScrollTo("#AddEditGoals", 400); + var ajaxRequest = piwikHelper.getStandardAjaxConf(); + piwikHelper.toggleAjaxLoading(); + var parameters = {}; parameters.idSite = piwik.idSite; parameters.name = encodeURIComponent( $('#goal_name').val() ); - + if($('[name=trigger_type]').val() == 'manually') { parameters.matchAttribute = 'manually'; parameters.patternType = 'regex'; parameters.pattern = '.*'; parameters.caseSensitive = 0; } else { - parameters.matchAttribute = $('input[name=match_attribute]:checked').val(); + parameters.matchAttribute = $('input[name=match_attribute][checked]').val(); parameters.patternType = $('[name=pattern_type]').val(); parameters.pattern = encodeURIComponent( $('input[name=pattern]').val() ); parameters.caseSensitive = $('#case_sensitive').attr('checked') == true ? 1: 0; } parameters.revenue = $('input[name=revenue]').val(); - parameters.idGoal = $('input[name=goalIdUpdate]').val(); - parameters.method = $('input[name=methodGoalAPI]').val(); + parameters.idGoal = $('input[name=goalIdUpdate]').val(); + parameters.method = $('input[name=methodGoalAPI]').val(); parameters.module = 'API'; parameters.format = 'json'; - parameters.token_auth = piwik.token_auth; + parameters.token_auth = piwik.token_auth; ajaxRequest.data = parameters; return ajaxRequest; } - -function bindListGoalEdit() -{ - $('a[name=linkEditGoal]').click( function() { - var goalId = $(this).attr('id'); - var goal = piwik.goals[goalId]; - initGoalForm("Goals.updateGoal", _pk_translate('Goals_UpdateGoal_js'), goal.name, goal.match_attribute, goal.pattern, goal.pattern_type, (goal.case_sensitive=='0' ? false : true), goal.revenue, goalId); - showAddNewGoal(); - return false; - }); - - $('a[name=linkDeleteGoal]').click( function() { - var goalId = $(this).attr('id'); - var goal = piwik.goals[goalId]; - if(confirm(sprintf(_pk_translate('Goals_DeleteGoalConfirm_js'), '"'+goal.name+'"'))) - { - $.ajax( getAjaxDeleteGoal( goalId ) ); - } - return false; - }); - - $('a[name=linkEditGoals]').click( function(){ - return showEditGoals(); - } ); -} - -function initAndShowAddGoalForm() -{ - initGoalForm('Goals.addGoal', _pk_translate('Goals_AddGoal_js'), '', 'url', '', 'contains', false, '0'); - return showAddNewGoal(); -}
\ No newline at end of file |