PageSourceSearch

https://carynzinn.co.nz/MyJs/tilt.contentManagement.js?v=80

js carynzinn.co.nz collected 2026-10-04 04:33:51 UTC 11,733 bytes, 303 lines download raw bytes

1ko.bindingHandlers.summernotebasic = new function () {
2    this.init = function (element, valueAccessor, allBindings) {
3        var value = valueAccessor();
4        var options = $.extend(value, {
5            height: 100,
6            toolbar: [
7                ["lists", ["ul", "ol", "paragraph"]]
8            ],
9            onblur: function () {
10                value($(element).code());
11            }
12        });
13        return $(element).summernote(options);
14    };
15    this.update = function (element, valueAccessor) {
16       
17            var value = valueAccessor();
18            $(element).code(value());
19       
20    };
21};
22
23
24$(document).ready(function () {
25
26    //hide this until it's ready
27    $("a.adv-edit-content-button").hide();
28    $("a.editContentButton").live("click", function (e, myName, myValue) {
29        var parentContainer = $(this).parents('.Zevero_ContentPanel').first();
30        contentService.showSaveCancelButtons(parentContainer);
31        contentService.editContent(parentContainer, $(this).attr("contentKey"));
32        
33    });
34
35    $("a.editUserContentButton").live("click", function (e, myName, myValue) {
36        var parentContainer = $(this).parents('.Zevero_ContentPanel').first();
37        contentService.showSaveCancelButtons(parentContainer);
38        contentService.editUserContent(parentContainer, $(this).attr("contentKey"));
39    });
40
41    $("a.saveContentButton").live("click", function (e, myName, myValue) {
42        var contentKey = $(this).attr("contentKey");
43        var parentContainer = $(this).parents('.Zevero_ContentPanel').first();
44        contentService.updateContent($('#' + contentKey).code(), contentKey, parentContainer);
45
46    });
47
48    $("a.saveUserContentButton").live("click", function (e, myName, myValue) {
49        var contentKey = $(this).attr("contentKey");
50        var parentContainer = $(this).parents('.Zevero_ContentPanel').first();
51        contentService.updateUserContent($('#' + contentKey).code(), contentKey, parentContainer);
52
53    });
54
55    $("a.cancelContentButton").live("click", function (e, myName, myValue) {
56        if (confirm("Are you sure you want to cancel? Any changes will not be saved.")) {
57            var contentKey = $(this).attr("contentKey");
58            var parentContainer = $(this).parents('.Zevero_ContentPanel').first();
59            contentService.resetContent(parentContainer, $(this).attr("contentKey"));
60        }
61
62    });
63
64    $("a.cancelUserContentButton").live("click", function (e, myName, myValue) {
65        if (confirm("Are you sure you want to cancel? Any changes will not be saved.")) {
66            var contentKey = $(this).attr("contentKey");
67            var parentContainer = $(this).parents('.Zevero_ContentPanel').first();
68            contentService.resetUserContent(parentContainer, $(this).attr("contentKey"));
69        }
70
71    });
72
73});
74
75var contentService = new function () {
76    //set up the path to the  web service operations
77    var getContentUrl = '/SharedWebService/ContentService.svc/ContentService/GetContent';
78    var getUserContentUrl = '/SharedWebService/ContentService.svc/ContentService/GetUserContent'
79
80    var toggleMainContentDivVisibility = function (show) {
81       
82            
83    }
84
85    var showSaveCancelButtons = function (parentContainer)
86    {
87        parentContainer.find('.edit-content-button-container').fadeOut();
88        parentContainer.find('.save-content-button-container').fadeIn();
89    }
90
91    var hideSaveCancelButtons = function (parentContainer)
92    {
93        parentContainer.find('.save-content-button-container').fadeOut();
94        parentContainer.find('.edit-content-button-container').fadeIn();
95    }
96
97    //bind the main content
98    var bindMainContent = function (contentKey) {
99        
100    }
101
102    var bindContent = function (contentKey, element) {
103        //set up the parameter variables
104        var parameters = { contentKey: contentKey };
105        //Use the dataservice to make an ajax call passing in the success and
106        //error functions declared in this service
107        dataService.getData(getContentUrl,
108            parameters, function (result) { bindContentSuccess(result, element, contentKey); }, null, null, "GET");
109    }
110
111    var bindContentSuccess = function (result, element, contentKey) {
112
113        element.html(result);
114    }
115
116    var resetContent = function (parentContainer, contentKey) {
117        //Use the dataservice to make an ajax call passing in the success and
118        getContent(resetContentSuccess, parentContainer, contentKey, getContentUrl);
119    }
120
121    var resetUserContent = function (parentContainer, contentKey) {
122        //Use the dataservice to make an ajax call passing in the success and
123        getContent(resetContentSuccess, parentContainer, contentKey, getUserContentUrl);
124    }
125
126    var editContent = function (parentContainer, contentKey) {
127        //Use the dataservice to make an ajax call passing in the success and
128        parentContainer.find('.user-content-button').hide();
129        parentContainer.find('.tenant-content-button').show();
130        getContent(editContentSuccess, parentContainer, contentKey, getContentUrl);
131    }
132
133    var editUserContent = function (parentContainer, contentKey) {
134        //Use the dataservice to make an ajax call passing in the success and
135        getContent(editContentSuccess, parentContainer, contentKey, getUserContentUrl);
136    }
137
138    var getContent = function (successFunction, parentContainer, contentKey, requestUrl) {
139        //set up the parameter variables
140        var showDefault = false;
141        parameters = { contentKey: contentKey }
142        if (parentContainer.attr('showdefaultfullpagecontent') != null)
143        {
144            showDefault = (parentContainer.attr('showdefaultfullpagecontent').toLowerCase() === 'true');
145            parameters = { contentKey: contentKey, includedDefaultFullPageContent: showDefault };
146        }
147           
148        
149        
150        //error functions declared in this service
151        dataService.getData(requestUrl,
152            parameters, function (result) { successFunction(result, parentContainer, contentKey, showDefault); }, null, null, "GET");
153    }
154
155    function editContentSuccess(content, parentContainer, contentKey, showDefault) {
156        //get the button group container as this should be the top
157        var saveCancelButtonGroup = $('#' + contentKey).parent().find('.edit-content-button-container').first();
158        if (saveCancelButtonGroup != null)
159            tiltUtilities.scrollToElementWithElement(saveCancelButtonGroup, null, 100);
160        
161        var minHeight = "50px";
162        if (showDefault != null) {
163            if (showDefault == true)
164                minHeight = "400px";
165        }
166        setUpTenantEditor(contentKey, minHeight);
167
168        
169        
170        
171    }
172
173    function resetContentSuccess(content, parentContainer, contentKey) {
174        var contentDiv = $('#' + contentKey);
175        contentDiv.destroy();
176        hideSaveCancelButtons(parentContainer);
177        contentDiv.html(content);
178        tiltUtilities.scrollToElementWithElement(contentDiv, null, 100);
179    }
180
181
182
183    function setUpTenantEditor(editorElementId, minHeight)
184    {
185        var contentDiv = $('#' + editorElementId);
186        contentDiv.summernote({
187            focus: true,
188            onImageUpload: function (files, editor, $editable) {
189                contentEditingService.sendFile(files[0], editor, $editable);
190            }
191        });
192        if (minHeight != null) {
193            contentDiv.parent().find('.note-editor').css("min-height", minHeight);
194        }
195    }
196
197
198    var updateContent = function (content, contentKey, parentContainer) {
199
200      
201            //set up the path to the two web service operations
202            var updateMethod = '/MyAthletes/SettingsService.svc/SettingsService/UpdateContent'
203            //set up the parameter variables
204            var jsonData = {
205                contentKey: contentKey
206            , content: content
207            };
208
209            //call the webservice to save the data
210            return dataService.getData(updateMethod,
211               JSON.stringify(jsonData), function () { contentSavedSuccess(content, contentKey, parentContainer); });
212    }
213
214    var updateUserContent = function (content, contentKey, parentContainer) {
215
216        //set up the path to the two web service operations
217        var updateMethod = '/MyTraining/MyTrainingService.svc/MyTrainingService/UpdateContent'
218        //set up the parameter variables
219        var jsonData = {
220            contentKey: contentKey
221        , content: content
222        };
223
224        //call the webservice to save the data
225        return dataService.getData(updateMethod,
226           JSON.stringify(jsonData), function () { contentSavedSuccess(content, contentKey, parentContainer); });
227    }
228
229    var contentSavedSuccess = function (content, contentKey, parentContainer) {
230        var contentDiv = $('#' + contentKey);
231        contentDiv.destroy();
232        hideSaveCancelButtons(parentContainer);
233        tiltUtilities.scrollToElementWithElement(contentDiv, null, 100);
234        notificationService.ShowSpecificSuccessReplace('Content');
235    }
236
237
238    var setupDefaultUpload = function () {
239        setupContentUpload('#contentImageUploader', 'imageUrlList', null);
240    }
241
242    var setupContentUpload = function (uploadSelector, imageListSelector, viewModelInstance) {
243        contentService.getImageList(imageListSelector, viewModelInstance);
244        tiltFileUpload.initializeStandardImageFileUploader(uploadSelector, null, defaultImageUploadSuccess);
245        
246    }
247
248    var defaultImageUploadSuccess = function (selector, result) {
249        if (result.result.toString().indexOf('Error:') === -1) {
250            contentService.getImageList('imageUrlList', null);
251        }
252        else {
253            notificationService.ShowSpecificError(result.result);
254        }
255    }
256
257    var setEditorContent = function (elementId, value) {
258        $('#' + elementId).code(value);
259    }
260
261    var getEditorContent = function (elementId) {
262        return $('#' + elementId).code();
263    }
264
265
266    //expose the functions
267    return {
268        bindMainContent: bindMainContent,
269        showSaveCancelButtons: showSaveCancelButtons,
270        hideSaveCancelButtons: hideSaveCancelButtons,
271        bindContent: bindContent,
272        editContent: editContent,
273        resetContent: resetContent,
274        resetUserContent: resetUserContent,
275        editUserContent: editUserContent,
276        updateContent: updateContent,
277        updateUserContent: updateUserContent,
278        setupDefaultUpload: setupDefaultUpload,
279        getContent: getContent,
280        toggleMainContentDivVisibility: toggleMainContentDivVisibility,
281        setUpTenantEditor: setUpTenantEditor,
282        getEditorContent: getEditorContent,
283        setEditorContent: setEditorContent
284    };
285
286}();
287
288//Class constructor for data object to bind to grid or to details.
289var tenantImageList = function (data, secondInstance) {
290    return {
291        ImageUrlList: ko.observableArray(data.ImageUrlList),
292        deleteImage: function (imageUrl) {
293            if (confirm('Are you sure you want to delete the image?')) {
294                contentService.deleteImage(imageUrl, secondInstance);
295            }
296        },
297        hideImageUrl: function(elem) { if (elem.nodeType === 1) $(elem).slideUp(function() { $(elem).remove(); }) }
298    }
299};
300
301var tenantImageListInstance = null;
302var imageListInstance2 = null;
303

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.