Produced by Araxis Merge on 5/10/2018 8:27:03 AM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
# | Location | File | Last Modified |
---|---|---|---|
1 | OSCIF MHED P3 Annie.zip\cms-staff-app-release-4.0.0@aff5ba84233.zip\MessagingApp\app\scripts\modules\unsaved_changes | unsaved_change_module.js | Thu Feb 22 10:28:51 2018 UTC |
2 | OSCIF MHED P3 Annie.zip\cms-staff-app-release-4.0.0@aff5ba84233.zip\MessagingApp\app\scripts\modules\unsaved_changes | unsaved_change_module.js | Wed May 9 13:07:33 2018 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 3 | 346 |
Changed | 2 | 6 |
Inserted | 0 | 0 |
Removed | 0 | 0 |
Whitespace | |
---|---|
Character case | Differences in character case are significant |
Line endings | Differences in line endings (CR and LF characters) are ignored |
CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
1 | 'use stric t'; | |
2 | ||
3 | angular.mo dule('unsa vedChanges ', []) | |
4 | ||
5 | .provide r('unsaved WarningsCo nfig', fun ction () { | |
6 | this.$ get = func tion () { | |
7 | retu rn { | |
8 | re loadMessag e: 'You ha ve not sav ed your ch anges. You may conti nue withou t saving o r return t o the entr y screen.' , | |
9 | ro uteEvents: ['$locati onChangeSt art'], | |
10 | mo dalOptions : { | |
11 | templateUr l: 'script s/modules/ unsaved_ch anges/unsa ved_change _modal.tmp l.html', | |
12 | backdrop: 'static', | |
13 | controller : 'unsaved WarningMod alControll er' | |
14 | } | |
15 | }; | |
16 | }; | |
17 | }) | |
18 | ||
19 | .service ('unsavedW arningShar edService' , | |
20 | functi on ($rootS cope, $rou te, $timeo ut, $uibMo dal, $loca tion, unsa vedWarning sConfig) { | |
21 | ||
22 | var _this = th is, | |
23 | al lForms = [ ], | |
24 | ar eAllFormsC lean = tru e, | |
25 | fu nctionsToU nbind = [a ngular.noo p], | |
26 | me ssages = { | |
27 | reload: un savedWarni ngsConfig. reloadMess age | |
28 | }; | |
29 | ||
30 | this .allFormsC lean = fun ction () { | |
31 | ar eAllFormsC lean = tru e; | |
32 | an gular.forE ach(allFor ms, functi on (item) { | |
33 | if (item.$ dirty) { | |
34 | areAllFo rmsClean = false; | |
35 | } | |
36 | }) ; | |
37 | re turn areAl lFormsClea n; | |
38 | }; | |
39 | ||
40 | this .cleanAllF orms = fun ction () { | |
41 | an gular.forE ach(allFor ms, functi on (item) { | |
42 | if (item.$ dirty) { | |
43 | item.$se tPristine( ); | |
44 | } | |
45 | }) ; | |
46 | }; | |
47 | ||
48 | this .registerF ormForWarn ing = func tion (form ) { | |
49 | if (allForms .length == = 0) { | |
50 | setup(); | |
51 | } | |
52 | al lForms.pus h(form); | |
53 | }; | |
54 | ||
55 | this .removeFor m = functi on (form) { | |
56 | var f DNS ex = allFo rms.indexO f(form); | |
57 | if (f DNS ex === -1) { | |
58 | return; | |
59 | } | |
60 | ||
61 | allForms.s plice(f DNS ex, 1); | |
62 | ||
63 | if (allForms .length == = 0) { | |
64 | tearDown() ; | |
65 | } | |
66 | }; | |
67 | ||
68 | func tion tearD own() { | |
69 | an gular.forE ach(functi onsToUnbin d, functio n (unbindF unction) { | |
70 | unbindFunc tion(); | |
71 | }) ; | |
72 | wi ndow.onbef oreunload = null; | |
73 | } | |
74 | ||
75 | this .confirmEx itOnWindow Close = fu nction () { | |
76 | if (!_this.a llFormsCle an()) { | |
77 | return mes sages.relo ad; | |
78 | } | |
79 | te arDown(); | |
80 | }; | |
81 | ||
82 | func tion setup () { | |
83 | wi ndow.onbef oreunload = _this.co nfirmExitO nWindowClo se; | |
84 | ||
85 | va r eventsTo WatchFor = unsavedWa rningsConf ig.routeEv ents; | |
86 | an gular.forE ach(events ToWatchFor , function (aEvent) { | |
87 | var unbind Function = $rootScop e.$on(aEve nt, functi on (event, nextLocat ion) { | |
88 | if (!_th is.allForm sClean()) { | |
89 | event. preventDef ault(); | |
90 | var mo dalInstanc e = $uibMo dal.open(u nsavedWarn ingsConfig .modalOpti ons); | |
91 | modalI nstance.re sult.then( function ( ) { | |
92 | _thi s.cleanAll Forms(); | |
93 | if ( event.name === '$loc ationChang eStart') { | |
94 | va r nextLoca tionPath = nextLocat ion.split( '#')[1]; | |
95 | $l ocation.pa th(nextLoc ationPath) ; | |
96 | } | |
97 | }); | |
98 | } | |
99 | }); | |
100 | functionsT oUnbind.pu sh(unbindF unction); | |
101 | }) ; | |
102 | } | |
103 | } | |
104 | ) | |
105 | ||
106 | // Apply this to e lements th at clear f orm $dirty flags to prevent sh owing the unsaved wa rning mess age, e.g. cancel but tons. | |
107 | .directi ve('unsave dWarningCl ear', func tion () { | |
108 | return { | |
109 | scop e: {}, | |
110 | requ ire: '^for m', | |
111 | prio rity: 10, | |
112 | link : function (scope, e lement, at trs, formC trl) { | |
113 | el ement.bind ('click', function ( ) { | |
114 | formCtrl.$ setPristin e(); | |
115 | }) ; | |
116 | } | |
117 | }; | |
118 | }) | |
119 | ||
120 | // Apply this dire ctive to e lements th at cause f orm data l oss that w ould requi re an unsa ved change warning. | |
121 | // Only apply to e lements th at do not start a lo cation or route chan ge (these are handle d by defau lt), but w ould cause data loss . | |
122 | .directi ve('unsave dWarningTr igger', fu nction ($u ibModal, u nsavedWarn ingSharedS ervice, un savedWarni ngsConfig) { | |
123 | return { | |
124 | rest rict: 'A', | |
125 | prio rity: 1, | |
126 | link : function (scope, e lement, at tr) { | |
127 | va r clickAct ion = attr .ngClick; | |
128 | el ement.unbi nd('click' ); | |
129 | el ement.bind ('click', function ( event) { | |
130 | if (!unsav edWarningS haredServi ce.allForm sClean()) { | |
131 | event.pr eventDefau lt(); | |
132 | var moda lInstance = $uibModa l.open(uns avedWarnin gsConfig.m odalOption s); | |
133 | modalIns tance.resu lt.then(fu nction () { | |
134 | unsave dWarningSh aredServic e.cleanAll Forms(); | |
135 | scope. $eval(clic kAction); | |
136 | }); | |
137 | } else { | |
138 | scope.$e val(clickA ction); | |
139 | } | |
140 | }) ; | |
141 | } | |
142 | }; | |
143 | }) | |
144 | ||
145 | // Apply this dire ctive to f orms you w ould like to see the unsaved c hange warn ing for | |
146 | .directi ve('unsave dWarningFo rm', funct ion (unsav edWarningS haredServi ce) { | |
147 | return { | |
148 | scop e: {}, | |
149 | requ ire: 'form ', | |
150 | link : function (scope, f ormElement , attrs, f ormCtrl) { | |
151 | ||
152 | un savedWarni ngSharedSe rvice.regi sterFormFo rWarning(f ormCtrl); | |
153 | ||
154 | fo rmElement. bind('subm it', funct ion () { | |
155 | if (formCt rl.$valid) { | |
156 | formCtrl .$setPrist ine(); | |
157 | } | |
158 | }) ; | |
159 | ||
160 | sc ope.$on('$ destroy', function ( ) { | |
161 | unsavedWar ningShared Service.re moveForm(f ormCtrl); | |
162 | }) ; | |
163 | } | |
164 | }; | |
165 | }) | |
166 | ||
167 | .control ler('unsav edWarningM odalContro ller', fun ction ($sc ope, $uibM odalInstan ce) { | |
168 | $scope .return = function() { | |
169 | $uib ModalInsta nce.dismis s(); | |
170 | }; | |
171 | ||
172 | $scope .continue = function () { | |
173 | $uib ModalInsta nce.close( ); | |
174 | }; | |
175 | } | |
176 | ); |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.